package com.cg.repository.impl;

import com.cg.grpc.Greeting;
import com.cg.grpc.HelloWorldServiceGrpc;
import com.cg.grpc.User;
import com.cg.repository.UserRepository;
import net.devh.boot.grpc.client.inject.GrpcClient;
import org.springframework.stereotype.Service;

@Service
public class UserRepositoryImpl implements UserRepository {

    @GrpcClient("spring-grpc-server")
    private HelloWorldServiceGrpc.HelloWorldServiceBlockingStub helloWorldServiceBlockingStub;

    @Override
    public String findUserNameById(Integer id) {

        Greeting greeting = helloWorldServiceBlockingStub.sayHello(User.newBuilder().setUsername("🚗").build());
        return greeting.getMessage();
    }
}
